import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: resolve => {
        require(['@/views/login.vue'], resolve);
    }
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: resolve => {
        require(['@/views/error-page/404.vue'], resolve);
    }
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: resolve => {
        require(['@//views/error-page/403.vue'], resolve);
    }
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: resolve => {
        require(['@/views/error-page/500.vue'], resolve);
    }
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/home',
    name: 'otherRouter',
    component: resolve => {
        require(['@/views/home/home.vue'], resolve);
    }
    // component: Main,
    // children: [{
    //     path: 'home',
    //     title: {
    //         i18n: 'home'
    //     },
    //     name: 'home_index',
    // }]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [{
        path: '/group',
        icon: 'ios-folder',
        name: 'group',
        title: 'Group',
        component: Main,
        children: [{
                path: 'page1',
                icon: 'ios-paper-outline',
                name: 'page1',
                title: 'Page1',
                component: resolve => {
                    require(['@/views/group/page1/page1.vue'], resolve);
                }
            },
            {
                path: 'page2',
                icon: 'ios-list-outline',
                name: 'page2',
                title: 'Page2',
                component: resolve => {
                    require(['@/views/group/page2/page2.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/page',
        icon: 'ios-paper',
        title: 'Page',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    }
];

// 工厂对应的菜单
export const factoryRouter = [{
        path: '/page11',
        icon: 'ios-paper',
        title: '脉链渠道',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page12',
        icon: 'ios-paper',
        title: '产品进场',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page13',
        icon: 'ios-paper',
        title: '代工寄售',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page14',
        icon: 'ios-paper',
        title: '组团出国',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page15',
        icon: 'ios-paper',
        title: '维修联盟',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page16',
        icon: 'ios-paper',
        title: '培训服务',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    }
];

// 经销商对应的菜单
export const dealerRouter = [{
        path: '/page21',
        icon: 'ios-paper',
        title: '代理脉链',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page22',
        icon: 'ios-paper',
        title: '发现终端',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page23',
        icon: 'ios-paper',
        title: '维修联盟',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page24',
        icon: 'ios-paper',
        title: '培训服务',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page25',
        icon: 'ios-paper',
        title: '物流储备',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    }
];

// 终端门店对应的菜单
export const terminalRouter = [{
        path: '/page31',
        icon: 'ios-paper',
        title: '加盟简介',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    },
    {
        path: '/page32',
        icon: 'ios-paper',
        title: '我要报修',
        name: 'page',
        component: Main,
        children: [{
            path: 'index',
            title: 'Page',
            name: 'page_index',
            component: resolve => {
                require(['@/views/page/page.vue'], resolve);
            }
        }]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    ...appRouter,
    ...factoryRouter,
    ...dealerRouter,
    ...terminalRouter,
    page500,
    page403,
    page404
];